package com.oa.co.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.oa.co.mapper.PerformanceMapper;
import com.oa.co.pojo.Performance;
import com.oa.co.service.PerformanceService;
import com.oa.co.vo.PerformanceBarVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("performanceService")
public class PerformanceServiceImpl implements PerformanceService {

    @Autowired
    private PerformanceMapper performanceMapper;

    @Override
    public PageInfo<Performance> selectPerformanceList(Integer page, Integer limit, String annual, String quarter) {

        Performance performance = new Performance();
        performance.setAnnual(annual);
        performance.setQuarter(quarter);

        if(page != null && limit != null){
            PageHelper.startPage(page,limit);
            List<Performance> performances = performanceMapper.selectPerformanceList(performance);
            PageInfo<Performance> pageInfo = new PageInfo<>(performances);
            return pageInfo;
        }else {
            List<Performance> performances = performanceMapper.selectPerformanceList(performance);
            PageInfo<Performance> pageInfo = new PageInfo<>(performances);
            return pageInfo;
        }
    }

    @Override
    public int delPerformance(Integer id) {
        return performanceMapper.delPerformance(id);
    }

    @Override
    public int performanceEdit(Performance performance) {
        return performanceMapper.performanceEdit(performance);
    }

    @Override
    public int performanceAdd(Performance performance) {
        return performanceMapper.performanceAdd(performance);
    }

    @Override
    public List<PerformanceBarVo> performanceBarData() {
        return performanceMapper.performanceBarData();
    }

    @Override
    public int delAllPerformance(List<Integer> ids) {
        return performanceMapper.delAllPerformance(ids);
    }

}
